import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class HomeNav extends StatelessWidget {
  HomeNav({Key? key}) : super(key: key);
  final List navList = [
    {
      'title': '我的房屋',
      'icon': 'assets/images/house_nav_icon@2x.png',
    },
    {
      'title': '我的报修',
      'icon': 'assets/images/repair_nav_icon@2x.png',
    },
    {
      'title': '访客登记',
      'icon': 'assets/images/visitor_nav_icon@2x.png',
    }
  ];

  List<Widget> getListView(BuildContext context) {
    List<Widget> list = [];
    for (int i = 0; i < navList.length; i++) {
      list.add(
        GestureDetector(
            onTap: () async {
              if (i == 0) {
                Navigator.pushNamed(context, 'house');
              } else if (i == 1) {
              } else {}
              // if (i == 0) {
              //   tokenManager.setPre('asdasdasd');
              // }

              // final SharedPreferences aa =
              //     await SharedPreferences.getInstance();
              // // shared_preferences
              // if (i == 0) {
              //   aa.setInt('money', 20000);
              // } else if (i == 1) {
              //   print(aa.getInt('money'));
              // } else {
              //   aa.remove('money');
              // }
              // Fluttertoast.showToast(msg: '测试');
              // showAboutDialog(context: context);
              // showDialog(
              //     context: context,
              //     builder: (BuildContext context) {
              //       return Container(
              //         width: 500,
              //         height: 500,
              //         color: Colors.red,
              //         child: Column(children: [
              //           Text('1'),
              //           Text('1'),
              //           Text('1'),
              //         ]),
              //       );
              //     });
              // showDatePicker(
              //     context: context,
              //     initialDate: DateTime.now(),
              //     firstDate: DateTime.now(),
              //     lastDate: DateTime.now());

              // ScaffoldMessenger.of(context).showSnackBar(SnackBar(
              //   action: SnackBarAction(
              //       label: '确认',
              //       onPressed: () {
              //         print('8888');
              //       }),
              //   content: Text('111'),
              //   duration: Duration(seconds: 3),
              // ));
            },
            child: Column(
              children: [
                Image.asset(
                  navList[i]['icon'],
                  width: 35,
                ),
                Text(navList[i]['title'])
              ],
            )),
      );
    }
    return list;
  }

  @override
  Widget build(BuildContext context) {
    return Container(
        padding: const EdgeInsets.all(10),
        margin: const EdgeInsets.symmetric(vertical: 10),
        decoration: const BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(10)),
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceAround,
          children: getListView(context),
        ));
  }
}
